package org.ens.delegation.bo;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author amine
 *
 */
@Entity
@Table(name="service")
public class Service implements IBusinessObject<Integer>{

	private Integer id;
	private String description;
	private List<Agent> listAgent;
	
	@Override
	@Id
	@Column(name="code_serv")
	public Integer getId() {
		return id;
	}
	
	@Override
	public void setId(Integer id) {
		this.id = id;
	}
	
	@Column(name="description")
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany(mappedBy="service")
	public List<Agent> getListAgent() {
		return listAgent;
	}

	public void setListAgent(List<Agent> listAgent) {
		this.listAgent = listAgent;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null || !(obj instanceof Service))
			return false;
		Service service = (Service) obj;
		if(service.getId() == null)
			return false;
	
		return service.getId().equals(this.getId());
	}
	
}
